package cn.iocoder.yudao.module.member.controller.app.activation;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.controller.admin.activation.userVo.UserActivationSaveReqVO;
import cn.iocoder.yudao.module.member.controller.admin.job.vo.AppJobRespVO;
import cn.iocoder.yudao.module.member.controller.admin.jobcollection.vo.JobCollectionPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.jobcollection.vo.JobCollectionRespVO;
import cn.iocoder.yudao.module.member.controller.admin.jobcollection.vo.JobCollectionSaveReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.jobcollection.JobCollectionDO;
import cn.iocoder.yudao.module.member.service.activation.UserActivationService;
import cn.iocoder.yudao.module.member.service.jobcollection.JobCollectionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

@Tag(name = "用户 APP - 兑换中心")
@RestController
@RequestMapping("/member/activation")
@Validated
public class AppActivationController {

    @Resource
    private UserActivationService activationService;

    @PostMapping("/create")
    @Operation(summary = "用户兑换激活码")
    @PermitAll
    public CommonResult createActivationCode(@Valid @RequestBody UserActivationSaveReqVO userActivationSaveReqVO) {
        Long userId = getLoginUserId();
        userActivationSaveReqVO.setUserId(userId);
        activationService.createActivationCode(userActivationSaveReqVO);
        return success(true);
    }

}